package com.tools;

import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class BICPanelImage extends JPanel {
	private static final long serialVersionUID = 1L;
	private Image image;

	public BICPanelImage() {
		super();
	}
	public BICPanelImage(Image image) {
		this.image = image;
	}

	public BICPanelImage(String path) {
		try {
			this.image = ImageIO.read(new File(path));
		} catch (IOException e) {
			JOptionPane
					.showMessageDialog(null, "Impossible de charger l'image");
		}
	}

	public BICPanelImage(File file) {
		try {
			this.image = ImageIO.read(file);
		} catch (IOException e) {
			JOptionPane
					.showMessageDialog(null, "Impossible de charger l'image");
		}
	}

	public Image getImage() {
		return image;
	}
	public void setImage(Image image) {
		this.image = image;
	}
	public void setImage(String path) {
		try {
			this.image = ImageIO.read(new File(path));
		} catch (IOException e) {
	JOptionPane.showMessageDialog(null,"Impossible de mettre a jour l'image");
		}
	}
	
	public void setImage(File file) {
		try {
			this.image = ImageIO.read(file);
		} catch (IOException e) {
	JOptionPane.showMessageDialog(null,"Impossible de mettre a jour l'image");
		}
	}
	@Override
	public void paintComponent(Graphics g) {
		g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
	}
}
